package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.SurveyDepotSubject;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SurveyDepotSubjectDAO{
	
	@SQL("SELECT * FROM SurveyDepotSubject WHERE deleteFlag=1 AND surveyDepotId=:t.surveyDepotId ORDER BY id ASC LIMIT :t.start,:t.length")
    List<Map> query(@SQLParam("t") SurveyDepotSubject voteSubject);
	
	@SQL("SELECT count(*) FROM SurveyDepotSubject WHERE deleteFlag=1 AND surveyDepotId=:t.surveyDepotId ")
    int querysize(@SQLParam("t") SurveyDepotSubject voteSubject);
    
    @SQL("select * from SurveyDepotSubject where id=:1")
    SurveyDepotSubject queryById(int id);
    
    @ReturnGeneratedKeys
    @SQL("INSERT INTO SurveyDepotSubject (surveyDepotId,subject,isMutil,deleteFlag,createUser,createAt,updateUser,updateAt,count,answers) VALUES (:1,:3,:2,1,:4,now(),:4,now(),:5,:6)")
    int create(int surveyDepotId, int isMutil, String subject, String user,int count,String answers);
    
	@SQL("UPDATE SurveyDepotSubject SET subject=:3,isMutil=:2,updateUser=:4,updateAt=now(),count=:5,answers=:6 WHERE id=:1")
	void update(int surveyDepotSubjectId, int isMutil, String subject, String user, int count,String answers);
	
//	@SQL("UPDATE SurveyDepotSubject SET answers=:2 WHERE id=:1")
//	void update(int surveyDepotSubjectId, String answers);
    
    @SQL("UPDATE SurveyDepotSubject SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}